/*!
 * JavaScript Autoslider
 *
 * Copyright 2011, Bern hard Bezdek
 * Licensed under the GPL Version 2 license.
 * @requires Jquery min. 1.5.x
 *
 * Date: Thu Jul 03 14:16:56 2011 -0400
 *
 * Note This is a modified Version of the auto0lisde function by Bernhard Bezdek
 * The origin you can find on googlecode
 * http://code.google.com/p/appstackio-public-sources/
 */
 
 function autoslide(oSlider, sElement, iUnit, iDelay, iDuration) {
	var iCurMargin = parseInt($(oSlider).css('margin-left').replace(/px/, ''));
	iCurMargin = (iCurMargin<0)?iCurMargin*-1:iCurMargin;

	var iMaxSlide = $(oSlider).children(sElement).length*iUnit;

	$(oSlider).width(iMaxSlide);

	if((iCurMargin+iUnit)<iMaxSlide) {
		$(oSlider).delay(iDelay).animate({
			'margin-left':'-'+(iCurMargin+iUnit)+'px'
		}, iDuration, function() {
			autoslide(oSlider, sElement, iUnit, iDelay, iDuration);
		});
	} else {
		$(oSlider).delay(iDelay).animate({
			'opacity':'0'
		}, 250, function() {
			$(oSlider).css('margin-left','0px');
			$(oSlider).animate({
				'opacity':'1'
			}, 250, function() {
				autoslide(oSlider, sElement, iUnit, iDelay, iDuration);
			});
		});
	}
}
